package tosp.search;

import java.util.Vector;

import org.apache.log4j.Logger;

import tosp.HistoryMachine;
import tosp.JobSequence;
import tosp.job.Job;

public class RotateNeigbhborSearch extends LocalSearchAdapter {

	static Logger log = Logger.getLogger(RotateNeigbhborSearch.class);
	
	public RotateNeigbhborSearch(HistoryMachine m) {
		super(m);
	}

	// diese wir hier nicht genutzt
	@Override
	public JobSequence[] getNeighbors(JobSequence j) {
		return null;
	}

	@Override
	public JobSequence getNeighbor(JobSequence j, int o) {
		Job[] in=j.jobs;
		Vector<Job> r=new Vector<Job>(in.length);
		
		if (o>in.length) return null;
		
		for (int i=0;i<in.length;i++) {
			r.add(in[(i+o)%in.length]);
		}
		
		JobSequence newjs = new JobSequence(r,true);
		//log.trace("Generated new Neighbor: "+newjs.getSeqAsString());
		//log.debug("Generated 1 Neighbor");
		return newjs;
	}

	public int getNeighborSize(JobSequence j) {
		return j.getSize();
	}
	
}
